/*
 * Created on 22.07.2008
 *
 */
package com.appspot.yttv.client;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

/**
 * 
 * @author Uwe Maurer
 *
 */
public class PreferencesWidget extends DialogBox {
	private final Callback callback;

	
	public interface Callback {
		void onSuccess(String search);
	}
	
	public PreferencesWidget(String title, Callback  callback) {
		super(true, true);
		this.callback = callback;
		Panel panel = new FlowPanel();
		add(panel);
		setText(title);
		final  TextBox feed = new TextBox();
		Button button = new Button("Search");
		button.addClickListener(new ClickListener() {

			public void onClick(Widget sender) {
				PreferencesWidget.this.callback.onSuccess(feed.getText());
				hide();
			}
			
		});
		panel.add(feed);
		panel.add(button);
		feed.setFocus(true);
	}
}
